package com.dq.eduservice.controller.front;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.dq.commonutils.pojo.DqException;
import com.dq.commonutils.vo.Result;
import com.dq.eduservice.entity.EduTeacher;
import com.dq.eduservice.service.EduTeacherService;
import com.dq.eduservice.vo.TeacherVo;
import com.dq.eduservice.vo.param.PageParam;
import com.dq.eduservice.vo.param.front.TeacherParam;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

/**
 * @project: guli_parent
 * @ClassName: TeacherFrontController
 * @author: dq
 * @creat: 2022/8/12 13:55
 */
@RestController
@RequestMapping("/eduservice/teacherfront")
@CrossOrigin
public class TeacherFrontController {

    @Autowired
    private EduTeacherService teacherService;

    /**
     * 获取所有老师列表
     * @param teacherParam
     * @return
     */
    @PostMapping("getTeacherList")
    public Result getTeacherPage(@RequestBody TeacherParam teacherParam){
        Page<EduTeacher> page = new Page<>(teacherParam.getCurrentPage(), teacherParam.getPageSize());
        Map<String,Object> resultMap = teacherService.getFrontTeacherList(page);
        return Result.success(resultMap);
    }

    /**
     * 根据老师查询信息和他所教的课程
     * @param id
     * @return
     */
    @GetMapping("/getTeacherInfo/{id}")
    public Result getTeacherInfoById(@PathVariable("id") String id){
        TeacherVo teacherVo =teacherService.getTeacherInfoById(id);

        return Result.success(teacherVo);
    }
}
